import java.io.File;
import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Scanner;
import java.util.regex.Pattern;

public class labLexer {
    static HashMap<String, String> keywords = new HashMap<>();
    static HashMap<String, String> symbols = new HashMap<>();
    static int pointer;

    public static void main(String[] args) throws FileNotFoundException {
        init();
        File file = new File(args[0]);
        Scanner input = new Scanner(file);
        while (input.hasNextLine()) {
            String str = input.nextLine();
            analyze(str);
        }
    }

    public static void init() {
        //关键字
        keywords.put("if", "If");
        keywords.put("else", "Else");
        keywords.put("while", "While");
        keywords.put("break", "Break");
        keywords.put("continue", "Continue");
        keywords.put("return", "Return");
        //符号
        symbols.put("=", "Assign");
        symbols.put(";", "Semicolon");
        symbols.put("(", "LPar");
        symbols.put(")", "RPar");
        symbols.put("{", "LBrace");
        symbols.put("}", "RBrace");
        symbols.put("+", "Plus");
        symbols.put("*", "Mult");
        symbols.put("/", "Div");
        symbols.put("<", "Lt");
        symbols.put(">", "Gt");
        symbols.put("==", "Eq");
    }

    public static void analyze(String s) {
        pointer = 0;
        s = s.trim();
        char c;
        while (pointer < s.length()) {
            c = s.charAt(pointer);
            if (Character.isDigit(c)) {
                checkDigit(s);
            } else if (Character.isLetter(c) || c == '_') {
                checkLetter(s);
            } else if (Pattern.compile("\\s").matcher(c+"").matches()) {
                pointer++;
            } else {
                checkSymbol(s);
            }
        }
    }

    //匹配数字
    public static void checkDigit(String s) {
        StringBuilder re = new StringBuilder();
        while (pointer < s.length() && Character.isDigit(s.charAt(pointer))) {
            re.append(s.charAt(pointer++));
        }
        System.out.println("Number(" + re.toString() + ")");
    }

    //匹配标识符
    public static void checkLetter(String s) {
        StringBuilder re = new StringBuilder();
        re.append(s.charAt(pointer++));
        while (pointer < s.length() && (Character.isLetterOrDigit(s.charAt(pointer)) || s.charAt(pointer) == '_')) {
            re.append(s.charAt(pointer++));
        }
        if (isKeyword(re.toString())) {
            System.out.println(keywords.get(re.toString()));
        } else {
            System.out.println("Ident(" + re.toString() + ")");
        }
    }

    //匹配符号
    public static void checkSymbol(String s) {
        char c = s.charAt(pointer);
        if (!symbols.containsKey(c + "")) {
            System.out.println("Err");
            System.exit(0);
        }
        if (c != '=') {
            pointer++;
            System.out.println(symbols.get(c + ""));
        } else {
            if (pointer + 1 < s.length() && s.charAt(pointer + 1) == '=') {
                pointer += 2;
                System.out.println("Eq");
            } else {
                pointer++;
                System.out.println("Assign");
            }
        }
    }

    public static Boolean isKeyword(String s) {
        return keywords.containsKey(s);
    }
}
